#ifndef CATEGORYDETAIL_H
#define CATEGORYDETAIL_H


//  tungvc  : CacteryDeatail : thong tin chi tiet ve tung category: id, name, list cac bai viet

#include <QObject>
#include <QList>
#include "article.h"

class CategoryInfo : public QObject
{
    Q_OBJECT
public:
    explicit CategoryInfo(const int idCategory, const int idSource, QObject *parent = 0)
        :QObject(parent)
        ,m_id(idCategory)
        ,m_name("")
        ,m_idSource(idSource)

    {
    }

    CategoryInfo(const int idCategory, const QString& name, QObject *parent = 0)
            :QObject(parent)
            ,m_id(idCategory)
            ,m_name(name)
            ,m_idSource(-1)

        {
        }

    CategoryInfo(const CategoryInfo& cInfo):
         QObject()
        ,m_id ( cInfo.getId())
        , m_name(cInfo.getName())
        , m_idSource(cInfo.getIdSource())
    {

    }

    void operator =(const CategoryInfo& cInfo)
    {
        m_id = cInfo.getId();
        m_name = cInfo.getName();
        m_idSource = cInfo.getIdSource();
    }

    inline int getId() const {
        return m_id;
    }

    inline int getIdSource() const {
        return m_idSource;
    }

    inline QString getName()const {
        return m_name;
    }

    inline void setIdSource(const int idSource){
        m_idSource = idSource;
    }

private:
    int m_id;
    QString m_name;
    int m_idSource;


};


class CategoryDetail : public QObject
{
    Q_OBJECT
public:
    explicit CategoryDetail(const int idCategory, const int idSource, QObject *parent = 0);

    CategoryDetail(    int _idCategory,
                       QList < int64_t > _listArticleId,
                       QList < Article* > _listArticleByCategory,
                       QObject *parent = 0);

    inline int idCategory() const {
        return m_cInfo.getId();
    }

    inline int idSource() const {
        return m_cInfo.getIdSource();
    }

    inline void setIdSource(const int idSource){
        m_cInfo.setIdSource(idSource);

    }

    inline QList < int64_t > listArticleId() const {
        return m_listArticleId;
    }

    inline QList < Article* > listArticleData() const {
        return m_listArticleData;
    }


    void addLastArticle(Article* aArticle) {
        m_listArticleData.append(aArticle);
        m_listArticleId.append(aArticle->getId());
    }

    void addFirstArticle(Article* aArticle) {
        m_listArticleData.push_front(aArticle);
        m_listArticleId.push_front(aArticle->getId());
    }

    void clearAllArticle() {
        m_listArticleData.clear();
        m_listArticleId.clear();
    }


    void setArticleData(QList<Article*> m_listArticleData);

private:

    CategoryInfo m_cInfo;
    QList < int64_t > m_listArticleId;
    QList < Article* > m_listArticleData;

};

#endif // ARTICLELISTBYCATEGORY_H
